/*
 * MFrame.h
 *
 *  Created on: 2017年3月16日
 *      Author: chuanjiang.zh
 */

#ifndef MFRAME_H_
#define MFRAME_H_

#include "MFormat.h"


/// pixel format.
enum MPixelFormat
{
	PIXEL_FORMAT_NONE = 0,
    PIXEL_FORMAT_I420,  /* yuv 4:2:0 planar */
    PIXEL_FORMAT_YV12,  /* yvu 4:2:0 planar */
    PIXEL_FORMAT_NV12,  /* yuv 4:2:0, with one y plane and one packed u+v */
    PIXEL_FORMAT_I422,
    PIXEL_FORMAT_I444,
    PIXEL_FORMAT_BGR,
    PIXEL_FORMAT_BGRA,
    PIXEL_FORMAT_RGB,    // RGB24
    PIXEL_FORMAT_YUY2,
    PIXEL_FORMAT_UYVY,
    PIXEL_FORMAT_RGB32,

    PIXEL_FORMAT_MAX /* end of list */
};


/**
 * 音频采样格式.
 */
enum MSampleFormat {
    MSAMPLE_FMT_NONE = -1,//!< MSAMPLE_FMT_NONE
    MSAMPLE_FMT_U8,          ///< unsigned 8 bits
    MSAMPLE_FMT_S16,         ///< signed 16 bits
    MSAMPLE_FMT_S32,         ///< signed 32 bits
    MSAMPLE_FMT_FLT,         ///< float
    MSAMPLE_FMT_DBL,         ///< double

    MSAMPLE_FMT_U8P,         ///< unsigned 8 bits, planar
    MSAMPLE_FMT_S16P,        ///< signed 16 bits, planar
    MSAMPLE_FMT_S32P,        ///< signed 32 bits, planar
    MSAMPLE_FMT_FLTP,        ///< float, planar
    MSAMPLE_FMT_DBLP,        ///< double, planar

    MSAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
};

enum MConst
{
	MAX_PLANE = 8	/// 最大平面数.
};

/// 音视频帧.
struct MFrame
{
	int type;	///@see MFrameType, 用于区分音频/视频.
	int fmt;	/// 帧格式, @see MPixelFormat. 对于音频, @see MSampleFormat

	unsigned char* data[MAX_PLANE];	/// 媒体数据, 对于视频, 每个元素指向一个平面;对于音频, 元素指向通道.
	int linesize[MAX_PLANE];		/// 第几个平面|通道的字节数.

	int64_t pts;	/// 时间戳.
	int flags;		/// 标记.

	/// for video only
	int width;		/// 视频高.
	int height;		/// 视频宽.

	/// for audio only
	int channels;	/// 音频通道.
	int sampleRate;	/// 采样率.
	int samples;	/// 采样数.

};



#endif /* MFRAME_H_ */
